//
//  NSString+WDLBase64.m
//  24-加密
//
//  Created by 王道林 on 16/8/16.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "NSString+WDLBase64.h"

@implementation NSString (WDLBase64)


- (NSString *)stringWithBase64
{
    // 字符串 转 NSData
    NSData *stringData = [self dataUsingEncoding:NSUTF8StringEncoding];
    // NSData 进行Base64, 生成字符串
   NSString *base64String = [stringData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    
    return base64String;
}

- (NSString *)Base64WithString
{
    // 根据Base64字符串, 生成NSData;
    NSData *base64Data = [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
    // 把NSData转化成字符串
    NSString *orginString = [[NSString alloc] initWithData:base64Data encoding:NSUTF8StringEncoding];
    return orginString;
    
}



@end
